<?php $myCartObj = new Cart(); $myCartInfo = $myCartObj->getMyCart();$siteConfig=new Config("site_config");?>
<?php $siteConfigObj = new Config("site_config");$site_config   = $siteConfigObj->getInfo();?>
<?php $iurl = IUrl::creatUrl();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $siteConfig->name;?></title>
<link rel="stylesheet" href="<?php echo IUrl::creatUrl("")."views/".$this->theme."/skin/".$this->skin."/css/index.css";?>" />
<script type='text/javascript' src="<?php echo IUrl::creatUrl("")."views/".$this->theme."/javascript/common.js";?>"></script>
<script charset="UTF-8" src="/runtime/systemjs/jquery-1.4.4.min.js"></script>
<script charset="UTF-8" src="/runtime/systemjs/form.js"></script>
<script charset="UTF-8" src="/runtime/systemjs/artdialog/artDialog.min.js"></script>
<link rel="stylesheet" type="text/css" href="/runtime/systemjs/autovalidate/style.css"/><script charset="UTF-8" src="/runtime/systemjs/autovalidate/validate.js"></script>
</head>
<body class="index">
<div class="ucenter container">
	<div class="header">
		<h1 class="logo"><a title="<?php echo $siteConfig->name;?>" style="background:url(<?php echo IUrl::creatUrl("")."image/logo.gif";?>);" href="<?php echo IUrl::creatUrl("");?>"><?php echo $siteConfig->name;?></a></h1>
		<ul class="shortcut">
			<li class="first"><a href="<?php echo IUrl::creatUrl("/ucenter/index");?>">我的账户</a></li><li><a href="<?php echo IUrl::creatUrl("/ucenter/order");?>">我的订单</a></li><!-- <li class='last'><a href="<?php echo IUrl::creatUrl("/site/help_list");?>">使用帮助</a></li> -->
		</ul>
		<?php $user = $this->user;?>
		<p class="loginfo"><?php echo isset($user['username'])?$user['username']:"";?>您好，欢迎您来到<?php echo $siteConfig->name;?>购物！[<a class='reg' href="<?php echo IUrl::creatUrl("/simple/logout");?>">安全退出</a>]</p>
	</div>
	<div class="navbar">
		<ul>
			<li><a href="<?php echo IUrl::creatUrl("");?>">首页</a></li>
			<?php $query = new IQuery("guide");$items = $query->find(); foreach($items as $key => $item){?>
			<li><a href="<?php echo isset($item['link'])?$item['link']:"";?>"><?php echo isset($item['name'])?$item['name']:"";?><span> </span></a></li>
			<?php }?>
		</ul>
		<div class="mycart">
			<dl>
				<dt><a href="<?php echo IUrl::creatUrl("/simple/cart");?>">购物车<b name="mycart_count"><?php echo isset($myCartInfo['count'])?$myCartInfo['count']:"";?></b>件</a></dt>
				<dd><a href="<?php echo IUrl::creatUrl("/simple/cart");?>">去结算</a></dd>
			</dl>

			<!--购物车浮动div 开始-->
			<div class="shopping" id='div_mycart' style='display:none;'>
			</div>
			<!--购物车浮动div 结束-->

		</div>
	</div>

	<div class="searchbar">
		<div class="allsort">
			<a href="javascript:void();">全部商品分类</a>

			<!--总的商品分类-开始-->
			<ul class="sortlist" id='div_allsort' style='display:none'>
				<?php $catResult = block::goods_category();?>
				<?php foreach($catResult as $key => $first){?>
					<li>
						<h2><a href="<?php echo IUrl::creatUrl("/site/pro_list/cat/$first[id]");?>"><?php echo isset($first['name'])?$first['name']:"";?></a></h2>

						<!--商品分类 浮动div 开始-->
						<div class="sublist" style='display:none'>

							<div class="items">
								<strong>选择分类</strong>
								<?php if(isset($first['second'])){?>
								<?php foreach($first['second'] as $key => $second){?>
								<dl class="category selected">
									<dt>
										<a href="<?php echo IUrl::creatUrl("/site/pro_list/cat/$second[id]");?>"><?php echo isset($second['name'])?$second['name']:"";?></a>
									</dt>

									<dd>
										<?php if(isset($second['more'])){?>
										<?php foreach($second['more'] as $key => $third){?>
										<a href="<?php echo IUrl::creatUrl("/site/pro_list/cat/$third[id]");?>"><?php echo isset($third['name'])?$third['name']:"";?></a>|
										<?php }?>
										<?php }?>
									</dd>
								</dl>
								<?php }?>
								<?php }?>

							</div>

						</div>
						<!--商品分类 浮动div 结束-->

					</li>
				<?php }?>

			</ul>
			<!--总的商品分类-结束-->

		</div>

		<div class="searchbox">

			<form method='get'>
				<input type='hidden' name='controller' value='site' />
				<input type='hidden' name='action' value='search_list' />
				<?php $word = IReq::get('word');?>
				<input class="text" type="text" name='word' id="word" autocomplete="off" value="<?php echo $word ? $word : '输入关键字...';?>" />
				<input class="btn" type="submit" value="商品搜索" onclick="checkInput('word','输入关键字...');" />
			</form>

			<!--自动完成div 开始-->
			<ul class="auto_list" style='display:none'></ul>
			<!--自动完成div 开始-->

		</div>
		<div class="hotwords">热门搜索：
			<?php $query = new IQuery("keyword");$query->where = "hot = 1";$query->limit = "5";$query->order = "`order` asc";$items = $query->find(); foreach($items as $key => $item){?>
			<?php $tmpWord = urlencode($item['word']);?>
			<a href="<?php echo IUrl::creatUrl("/site/search_list/word/$tmpWord");?>"><?php echo isset($item['word'])?$item['word']:"";?></a>
			<?php }?>
		</div>
	</div>

	<div class="position">
		您当前的位置： <a href="<?php echo IUrl::creatUrl("");?>">首页</a>&nbsp;&gt;&nbsp;我的账户
	</div>
	<div class="wrapper clearfix">
		<div class="sidebar f_l">
			<img src="<?php echo IUrl::creatUrl("")."views/".$this->theme."/skin/".$this->skin."/images/front/ucenter/ucenter.gif";?>" width="180" height="40" />
			<div class="box">
				<div class="title"><h2>交易记录</h2></div>
				<div class="cont">
					<ul class="list">
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/order");?>">我的订单</a></li>
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/integral");?>">我的积分</a></li>
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/redpacket");?>">我的代金券</a></li>
					</ul>
				</div>
			</div>
			<div class="box">
				<div class="title"><h2 class='bg2'>服务中心</h2></div>
				<div class="cont">
					<ul class="list">
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/refunds");?>">退款申请</a></li>
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/complain");?>">站点建议</a></li>
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/consult");?>">商品咨询</a></li>
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/evaluation");?>">商品评价</a></li>
					</ul>
				</div>
			</div>
			<div class="box">
				<div class="title"><h2 class='bg3'>应用</h2></div>
				<div class="cont">
					<ul class="list">
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/message");?>">短信息</a></li>
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/favorite");?>">收藏夹</a></li>
					</ul>
				</div>
			</div>
			<div class="box">
				<div class="title"><h2 class='bg4'>账户资金</h2></div>
				<div class="cont">
					<ul class="list">
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/account_log");?>">帐户余额</a></li>
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/online_recharge");?>">在线充值</a></li>
					</ul>
				</div>
			</div>
			<div class="box">
				<div class="title"><h2 class='bg5'>个人设置</h2></div>
				<div class="cont">
					<ul class="list">
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/address");?>">地址管理</a></li>
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/info");?>">个人资料</a></li>
						<li><a href="<?php echo IUrl::creatUrl("/ucenter/password");?>">修改密码</a></li>
					</ul>
				</div>
			</div>
		</div>
				<div class="main f_r">
            <div class='tabs'>
			<div class="uc_title m_10 tabs_menu">
				<label class="current node"><span>地址管理</span></label><label class="node" onclick='form_empty()'><span>添加地址</span></label>
			</div>
            <div class='tabs_content'>
                <div id="address_list" class="form_content m_10 node">
                    <div class="uc_title2 m_10"><strong>已保存的有效地址</strong></div>
                    <table  class="list_table" width="100%" cellpadding="0" cellspacing="0">
                        <col width="120px" />
                        <col width="120px" />
                        <col width="120px" />
                        <col width="120px" />
                        <col width="120px" />
                        <col />
                        <thead><tr><th>收货人</th><th>所在地区</th><th>街道地址</th><th>电话/手机</th><th>邮编</th><th>操作</th></tr></thead>
                        <tbody>
                        <?php foreach($this->address as $key => $item){?>
                            <tr <?php if($key%2==1){?>class='even'<?php }?>>
                                <td><?php echo isset($item['accept_name'])?$item['accept_name']:"";?></td><td id="sel<?php echo isset($item['id'])?$item['id']:"";?>"><?php echo isset($this->areas[$item['province']])?$this->areas[$item['province']]:"";?><?php echo isset($this->areas[$item['city']])?$this->areas[$item['city']]:"";?><?php echo isset($this->areas[$item['area']])?$this->areas[$item['area']]:"";?></td><td><?php echo isset($item['address'])?$item['address']:"";?></td><td><?php echo isset($item['mobile'])?$item['mobile']:"";?></td><td><?php echo isset($item['zip'])?$item['zip']:"";?></td><td class="blue"><a class="blue" href='javascript:void(0)' onclick='form_back(<?php echo JSON::encode($item);?>)'>修改</a>|<a class="blue" href="javascript:void(0)" onclick="delModel({link:'<?php echo IUrl::creatUrl("/ucenter/address_del/id/$item[id]");?>'});">删除</a>|<?php if($item['default']==1){?><a style="color:red" href="<?php echo IUrl::creatUrl("/ucenter/address_default/id/$item[id]/default/0");?>" >取消默认</a><?php }else{?><a class="blue" href="<?php echo IUrl::creatUrl("/ucenter/address_default/id/$item[id]/default/1");?>">设为默认</a><?php }?></a></td>
                            </tr>
                        <?php }?>
                        </tbody>

                    </table>
                </div>
            </div>
            </div>
			<div class="orange_box" id='address_form' >
			<form action='<?php echo IUrl::creatUrl("/ucenter/address_edit");?>' method='post' name='form'>
				<table class="form_table" width="100%" cellpadding="0" cellspacing="0">
					<col width="120px" />
					<col />
					<caption>收货地址</caption>
					<tr>
						<th><span class="red">*</span> 收货人姓名：</th><td><input name='id' type='hidden' value=''><input name='accept_name' class="normal" pattern='required' alt='收货人不能为空' type="text" /><label>收货人真实姓名，方便快递公司联系。</label></td>
					</tr>
					<tr>
						<th><span class="red">*</span> 所在地区：</th><td><select id='province' name="province" onchange="select_city(this.value,2);">
							<option value="">请选择省份</option>
							<?php $query = new IQuery("areas");$query->where = "parent_id = 0";$items = $query->find(); foreach($items as $key => $item){?><option value="<?php echo isset($item['area_id'])?$item['area_id']:"";?>" ><?php echo isset($item['area_name'])?$item['area_name']:"";?></option><?php }?>
							</select>
							<span id="selec2"></span><span id="selec3"></span></td>
					</tr>
					<tr>
						<th><span class="red">*</span> 街道地区：</th><td><input name='address' class="normal" pattern='required' alt='街道地区不能为空' type="text" /><label>真实详细收货地址，方便快递公司联系。</label></td>
					</tr>
					<tr>
						<th><span class="red">*</span> 邮政编码：</th>
						<td>
						<input name='zip' class="normal" pattern='^\d{6}$' alt='邮政编码格式不正确' type="text" /><label>邮政编码,如250000。</label>
						</td>
					</tr>
					<tr>
						<th><span class="red"></span> 电话号码：</th>
						<td>
						<input name='telphone' class="normal" pattern='phone' empty alt='电话号码格式不正确' type="text" /><label>电话号码,如010-12345688。</label>
						</td>
					</tr>
					<tr>
						<th><span class="red"></span> 手机号码：</th>
						<td><input name='mobile' class="normal" pattern='mobi' empty alt='手机号码格式不正确' type="text" /><label>手机号码，如：13588888888</label></td>
					</tr>
					<tr>
						<th><span class="red"></span> 设为默认：</th>
						<td>
						<label><input name='default' type='checkbox'  value='1'></label>
						</td>
					</tr>
					<tr><th></th><td><label class="btn_gray"><input type="submit" value="保存" /></label><a onclick="window.location.href='<?php echo IUrl::creatUrl("/ucenter/address");?>'" ><label class="btn_gray"><input type="reset" value="取消" /></label></a></td></tr>
				</table>
				</form>
			</div>
		</div>
<script type='text/javascript'>
	//获得选中的地区名称
	function select_city(city,style,current)
	{
		var arr = city.split(',');
		$.getJSON("<?php echo IUrl::creatUrl("/block/area_child");?>",{aid:arr[0]}, function(json)
		{
			if(style==2)
			{
				var select_html = '<select name="city" id="city" onchange="select_city(this.value,3);">';
				select_html += '<option value="">请选择城市</option>';
				for( a in json)
				{
					if(current == json[a]['area_id'])
						select_html +='<option value="'+json[a]['area_id']+'" selected="selected">'+json[a]['area_name']+'</option>';
					else
						select_html +='<option value="'+json[a]['area_id']+'">'+json[a]['area_name']+'</option>';
				}
				select_html +='</select>';
				$("#selec"+style).html(select_html);
			}
			if(style==3)
			{
				if(json.length>0)
				{
					var select_html = '<select name="area" id="area" onchange="select_city(this.value,4);">';
					select_html += '<option value="">请选择地区</option>';
					for( a in json)
					{
						if(current == json[a]['area_id'])
							select_html +='<option value="'+json[a]['area_id']+'" selected="selected">'+json[a]['area_name']+'</option>';
						else
							select_html +='<option value="'+json[a]['area_id']+'">'+json[a]['area_name']+'</option>';
					}
					select_html +='</select>';
					$("#selec"+style).show();
					$("#selec"+style).html(select_html);
				}
				else
				{
					//if($("#selec"+style).text()=='')
						$("#selec"+style).hide();
				}
			}
		});
	}
	function form_back(obj)
	{

		$('#address_list').css('display','none');
        //$('#address_form').css('display','none');
		var form = new Form('form');
        $('#address_form').slideDown("slow");
		form.init(obj);
		select_city(obj.province,2,obj.city);
		select_city(obj.city,3,obj.area);

	}
	function form_empty()
	{
		var form = new Form('form');
		form.init({"id":"","accept_name":"","zip":"","telphone":"","province":"","city":"","area":"","address":"","":"","default":""});
	}
</script>

	</div>


	<?php echo $siteConfig->site_footer_code;?>

</div>
<script type='text/javascript'>
	//tabs的通用代码
	(function($){
		$(".tabs").each(function(i){
		    var parrent = $(this);
			$('.tabs_menu .node',this).each(function(j){
				var current=".node:eq("+j+")";
				$(this).bind('click',function(event){
					$('.tabs_menu .node',parrent).removeClass('current');
					$(this).addClass('current');
					$('.tabs_content>.node',parrent).css('display','none');
					$('.tabs_content>.node:eq('+j+')',parrent).css('display','block');
				});
			});
		});
	})(jQuery);

	//隔行换色
	$(".list_table tr::nth-child(even)").addClass('even');
	$(".list_table tr").hover(
		function () {
			$(this).addClass("sel");
		},
		function () {
			$(this).removeClass("sel");
		}
	);
    //用户中心导航条
    function menu_current()
    {
        var current = "<?php echo $this->getAction()->getId();?>";
        if(current == 'consult_old') current='consult';
        else if(current == 'isevaluation') current ='evaluation';
        else if(current == 'withdraw') current = 'account_log';
        var tmpUrl = "<?php echo IUrl::creatUrl("/ucenter/current");?>";
        tmpUrl = tmpUrl.replace("current",current);
        $('div.cont ul.list li a:[href^="'+tmpUrl+'"]').parent().addClass("current");
    }
    menu_current();
</script>
<script type='text/javascript' src='<?php echo IUrl::creatUrl("")."views/".$this->theme."/javascript/site.js";?>'></script>
<script type='text/javascript'>
var url_head = 	encodeURIComponent('<?php echo isset($iurl)?$iurl:"";?>');
	$('input:text[name="word"]').bind({
		keyup:function(){autoComplete(decodeURIComponent(url_head)+'index.php'+decodeURIComponent('%2F')+'site'+decodeURIComponent('%2F')+'autoComplete','<?php echo IUrl::creatUrl("/site/search_list");?>','<?php echo isset($site_config['auto_finish'])?$site_config['auto_finish']:"";?>');}
	});

	//购物车div层
	$('.mycart').hover(
		function(){
			showCart('<?php echo IUrl::creatUrl("/simple/showCart");?>');
		},
		function(){
			$('#div_mycart').hide('slow');
		}
	);
</script>
</body>
</html>
